//
//  CustomView.m
//  01-UIViewHomeWork
//
//  Created by 冀永金 on 16/7/14.
//  Copyright © 2016年 QC.L. All rights reserved.
//

#import "CustomView.h"

@implementation CustomView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self config];
    }
    return self;
}
- (void)config {
    UIImageView *imageOfUser = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
    [self addSubview:imageOfUser];
    //imageOfUser.layer.cornerRadius = 10;
    imageOfUser.image = [UIImage imageNamed:@"icon_username"];
    imageOfUser.backgroundColor = [UIColor blackColor];
    UIImageView *imageOfPassword = [[UIImageView alloc]initWithFrame:CGRectMake(0, 55, 50, 50)];
    [self addSubview:imageOfPassword];
    imageOfPassword.image = [UIImage imageNamed:@"icon_password"];
    imageOfPassword.backgroundColor = [UIColor blackColor];
    UITextField *textfiledOfUser = [[UITextField alloc]initWithFrame:CGRectMake(50, 0, self.frame.size.width - 50, 50)];
    [self maskToCornerOfImage:imageOfPassword RoundingCorners:UIRectCornerBottomLeft cornerRedius:CGSizeMake(10, 10)];
    [self addSubview:textfiledOfUser];
    textfiledOfUser.backgroundColor = [UIColor blackColor];
    textfiledOfUser.alpha = 0.5;
   // textfiledOfUser.borderStyle = UITextBorderStyleRoundedRect;
    UITextField *textfiledOfPwd = [[UITextField alloc]initWithFrame:CGRectMake(50, 55, self.frame.size.width - 50, 50)];
    [self addSubview:textfiledOfPwd];
    textfiledOfPwd.backgroundColor = [UIColor blackColor];
    textfiledOfPwd.alpha = 0.5;
    [self maskToCorner:textfiledOfPwd RoundingCorners:UIRectCornerBottomRight cornerRedius:CGSizeMake(10, 10)];
    
}
- (void)maskToCorner:(UITextField *)view RoundingCorners:(UIRectCorner)corner cornerRedius:(CGSize)size {
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corner cornerRadii:size];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    maskLayer.frame = view.bounds;
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;
}
- (void)maskToCornerOfImage:(UIImageView *)view RoundingCorners:(UIRectCorner)corner cornerRedius:(CGSize)size {
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corner cornerRadii:size];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    maskLayer.frame = view.bounds;
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;
}




@end
